/*
 * Copyright 2010 Michael Nitsche
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package de.mnit.basis.grafik;

import de.mnit.basis.daten.MN;
import de.mnit.basis.daten.konstant.position.POSITION;


/**
 * @author Michael Nitsche
 * 12.12.2010	Erstellt
 */
public class BildRechner {

	/**
	 * Ergebnis = Einzug links/oben
	 */
	public static int[] ausrichtung(int flaeche_x, int flaeche_y, int bild_x, int bild_y, POSITION position) {
		int diff_x=flaeche_x-bild_x;
		int diff_y=flaeche_y-bild_y;
		int erg_x=0, erg_y=0;
		//X
		if(MN.oder(position, POSITION.LINKS, POSITION.LINKS_OBEN, POSITION.LINKS_UNTEN)) erg_x=0;
		if(MN.oder(position, POSITION.OBEN, POSITION.MITTE, POSITION.UNTEN)) erg_x=diff_x/2;
		if(MN.oder(position, POSITION.RECHTS, POSITION.RECHTS_OBEN, POSITION.RECHTS_UNTEN)) erg_x=diff_x;
		//Y
		if(MN.oder(position, POSITION.LINKS_OBEN, POSITION.OBEN, POSITION.RECHTS_OBEN)) erg_y=0;
		if(MN.oder(position, POSITION.LINKS, POSITION.MITTE, POSITION.RECHTS)) erg_y=diff_y/2;
		if(MN.oder(position, POSITION.LINKS_UNTEN, POSITION.UNTEN, POSITION.RECHTS_UNTEN)) erg_y=diff_y;
		return new int[]{erg_x, erg_y};
	}

}
